%m-file for Problem 4
load('shoesducks.mat');%load the data in

L=[];
kernel = 'linear';
for c=-6:2
   err = svm(X, Y, 10^c, kernel);
    %[nsv alpha bias] = svc(Xtest, Ytest, kernel, 10^c);
   %err = svcerror(Xtrain,Ytrain, Xtest, Ytest, kernel, alpha, bias)
   L = [L;[c,err]]
end
figure(1)
plot(L(:,1),L(:,2));
xlabel('log_{10}(x)');
ylabel('error');
print -depsc LC.pdf;

kernel = 'poly';
global p1;
P=[];
for p1 = 1:5
     err = svm(X, Y, 0.001, kernel);
     P = [P;[p1, err]];
end
figure(2)
plot(P(:,1),P(:,2));
xlabel('degree');
ylabel('error');
print -depsc PolyD.pdf;

kernel = 'poly';
PC=[];
p1 = 3;
for c=-6:2
    err = svm(X, Y, 10^c, kernel);
    PC=[PC;[c,err]];
end
figure(3)
plot(PC(:,1),PC(:,2));
xlabel('log_{10}(C)');
ylabel('error');
print -depsc PolyC.pdf;


kernel = 'rbf';
R=[];
for k=-5:3
    p1 = 2^k;
    err = svm(X, Y, 0.001, kernel);
    R=[R;[k,err]];
end
figure(4)
plot(R(:,1),R(:,2));
xlabel('log_{2}sigma');
ylabel('error');
print -depsc RbfS.pdf;

kernel = 'rbf';
RC=[];
p1=1/4;
for c=-6:2
    err = svm(X, Y, 10^c, kernel);
    RC=[RC;[c,err]];
end
figure(5)
plot(RC(:,1),RC(:,2));
xlabel('log_{10}(C)');
ylabel('error');
print -depsc RbfC.pdf;